package spbun.fileclean;

import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.List;

import spbun.fileclean.common.FileTravel;
import spbun.fileclean.common.FileUtil;
import spbun.fileclean.common.WatchThread;
import spbun.fileclean.dto.FileInfo;

/**
 * 扫描类
 * 
 * @author spbun
 *
 */
public class FileCleanScan {

	public static void main(String[] args) throws Exception {

		File forder = new File("D:\\GR\\windows\\Desktop\\网盘要上传\\Photo.照片");

		File destFile = new File(FileUtil.getWebAppBasePath(), "fileclean.imgnew.obj");

		// 应用级别
		startApp(forder, destFile);
	}

	public static void startApp(File forder, File destFile) throws Exception {

		FileTravel travel = new FileTravel(forder);

		long start = System.currentTimeMillis();

		new Thread(new WatchThread(travel)).start();

		travel.travel();
		long end = System.currentTimeMillis();

		List<FileInfo> list = travel.list;

		try (FileOutputStream fos = new FileOutputStream(destFile);
				ObjectOutputStream oos = new ObjectOutputStream(fos);) {
			oos.writeObject(list);
		}

		System.out.println(list.size());

		System.out.println("耗时：" + ((end - start) / 1000));

	}
}
